<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="用户ID">
              <a-input placeholder="请输入用户ID" v-model="queryParam.uid"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="用户昵称">
              <a-input placeholder="请输入用户昵称" v-model="queryParam.uname"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="实名">
              <a-input placeholder="请输入实名" v-model="queryParam.realname"></a-input>
            </a-form-item>
          </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="渠道ID">
                <a-input placeholder="请输入渠道ID" v-model="queryParam.chanid"></a-input>
              </a-form-item>
            </a-col>

            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="状态">
                <j-dict-select-tag placeholder="请选择状态"  v-model="queryParam.state" dictCode="audit_state"/>
              </a-form-item>
            </a-col>
            <a-col :xl="8" :lg="9" :md="10" :sm="24">
              <a-form-item label="提现时间">
                <j-date :show-time="true"  date-format="YYYY-MM-DD HH:mm:ss" placeholder="请选择开始时间" v-model="queryParam.ttime"></j-date> 至
                <j-date :style="display='inline'" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" placeholder="请选择结束时间" v-model="queryParam.dtime"></j-date>
              </a-form-item>
            </a-col>
<!--            <a-col  :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="至">
                <j-date  :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" placeholder="请选择结束时间" v-model="queryParam.dtime"></j-date>
              </a-form-item>
            </a-col>-->
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" style="margin-left: 5px" icon="download" @click="handleExportXls('开心网吧提现')">导出</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>

            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
<!--      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>-->
      <span class="tab-search">
        <button :class="{'btnclass':btnIsActive1}"  @click="searchType(0)" type="primary" icon="plus">提现列表</button>
        <button :class="{'btnclass':btnIsActive2}"  @click="searchType(1)" type="primary" icon="plus">待审核</button>
      </span>

<!--      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
        <a-button type="primary" icon="import">导入</a-button>
      </a-upload>-->
      <!-- 高级查询区域 -->
<!--      <j-super-query :fieldList="superFieldList" ref="superQueryModal" @handleSuperQuery="handleSuperQuery"></j-super-query>-->
<!--     未选中隐藏 <a-dropdown v-if="selectedRowKeys.length > 0">-->
      <a-dropdown >
        <a-menu slot="overlay">
<!--          <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>-->
          <a-menu-item key="2" @click="dataMake(0)"><a-icon type="check"/>批准</a-menu-item>
          <a-menu-item key="3" @click="dataMake(1)"><a-icon type="close"/>拒绝</a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
      </a-dropdown>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        class="j-table-force-nowrap"
        @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
<!--          <a @click="handleEdit(record)">编辑</a>-->
                <a-popconfirm title="确定批准吗?"  @confirm="() => audit(record,0)">
                  <a :disabled="record.state!=''&&record.state!=null?record.state=='审核中'?false:true:true">批准</a>
                </a-popconfirm>

                <a-divider type="vertical" />
                <a-popconfirm title="确定拒绝吗?" @confirm="() => audit(record,1)">
                  <a  :class="{'linkColor':!(record.state!=''&&record.state!=null?record.state=='审核中'?false:true:true)}"
                    :disabled="record.state!=''&&record.state!=null?record.state=='审核中'?false:true:true">拒绝</a>
                </a-popconfirm>
<!--          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a @click="handleDetail(record)">详情</a>
              </a-menu-item>
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
              <a-menu-item v-if="record.state==''||record.state==null?record.state==0?true:false:false">
                <a-popconfirm  title="确定批准吗?" @confirm="() => audit(record,0)">
                  <a>批准</a>
                </a-popconfirm>
              </a-menu-item >
              <a-menu-item v-if="record.state==''||record.state==null?record.state==0?true:false:false">
                <a-popconfirm title="确定拒绝吗?" @confirm="() => audit(record,1)">
                  <a>拒绝</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>-->
        </span>

      </a-table>
    </div>

    <moneydatahappycafe-modal ref="modalForm" @ok="modalFormOk"></moneydatahappycafe-modal>
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import MoneydatahappycafeModal from './modules/MoneydatahappycafeModal'
  import { deleteAction, getAction,downFile,getFileAccessHttpUrl } from '@/api/manage'
  import {filterMultiDictText} from '@/components/dict/JDictSelectUtil'

  export default {
    name: 'MoneydatahappycafeList',
    mixins:[JeecgListMixin, mixinDevice],
    components: {
      MoneydatahappycafeModal
    },
    data () {
      return {
        description: '开心网吧提现管理页面',
        // 表头
        columns: [
          {
            title: '序号',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'用户ID',
            align:"center",
            dataIndex: 'uid'
          },
          {
            title:'昵称',
            align:"center",
            dataIndex: 'uname'
          },
         /* {
            title:'渠道ID',
            align:"center",
            dataIndex: 'chanid'
          },*/
          {
            title:'实名',
            align:"center",
            dataIndex: 'realname'
          },
          {
            title:'渠道昵称',
            align:"center",
            dataIndex: 'channel'
          },
          /*{
            title:'应用编码',
            align:"center",
            dataIndex: 'app'
          },*/

          /*{
            title:'身份证号',
            align:"center",
            dataIndex: 'idcard'
          },*/
          {
            title:'合成等级',
            align:"center",
            dataIndex: 'maxcarlv'
          },
          {
            title:'累计观看视频次数',
            align:"center",
            dataIndex: 'videonum'
          },
          {
            title:'红包币余额',
            align:"center",
            dataIndex: 'cash'
          },
          /*{
            title:'配置表id金额',
            align:"center",
            dataIndex: 'moneyconfid'
          },*/
          {
            title:'金额',
            align:"center",
            dataIndex: 'money'
          },
          {
            title:'状态',
            align:"center",
            sorter: true,
            dataIndex: 'state'
          },
          {
            title:'注册时间',
            align:"center",
            dataIndex: 'regtime'
          },
          /*{
            title:'登录时间',
            align:"center",
            dataIndex: 'logintime'
          },*/
          {
            title:'提现时间',
            align:"center",
            dataIndex: 'ttime'
          },
          {
            title:'到账时间',
            align:"center",
            dataIndex: 'dtime'
          },
          {
            title:'返回结果',
            align:"center",
            dataIndex: 'data'
          },
          /*{
            title:'登录设备',
            align:"center",
            dataIndex: 'devicetype'
          },
          {
            title:'提现类型',
            align:"center",
            dataIndex: 'moneytype_dictText'
          },*/
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:147,
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          list: "",
          delete: "/moenydata/moneydatahappycafe/delete",
          deleteBatch: "/moenydata/moneydatahappycafe/deleteBatch",
          exportXlsUrl: "/moenydata/moneydatahappycafe/exportXls",
          importExcelUrl: "moenydata/moneydatahappycafe/importExcel",
          auditNo: "moenydata/moneydatahappycafe/auditNo",
          auditNoBatch: "moenydata/moneydatahappycafe/auditNoBatch",
          auditYes: "moenydata/moneydatahappycafe/auditYes",
          auditYesBatch: "moenydata/moneydatahappycafe/auditYesBatch",
        },
        dictOptions:{},
        superFieldList:[],
        btnIsActive1:true,
        btnIsActive2:false,
      }
    },
    created() {
      //document.getElementById("#btn1").addClass= 'btnclass';

    this.getSuperFieldList();

    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      }
    },
    watch:{
        '$route'(to,from){//监听路由是否变化
          if(to.params.code!=from.params.code){
            //console.log('菜单路由参数to:'+to.params.code+',from:'+from.params.code);
            this.url.list='/moenydata/moneydatahappycafe/list?num='+to.params.code;
            this.url.exportXlsUrl='/moenydata/moneydatahappycafe/exportXls?num='+to.params.code;
            this.loadData();
          }
          console.log('路径2:'+this.url.list);

        }
    },
    methods: {
      initDictConfig(){
      },
      getSuperFieldList(){
        let fieldList=[];
        fieldList.push({type:'string',value:'uid',text:'用户ID',dictCode:''})
        fieldList.push({type:'string',value:'uname',text:'用户昵称',dictCode:''})
        fieldList.push({type:'string',value:'channel',text:'渠道',dictCode:''})
        fieldList.push({type:'string',value:'realname',text:'实名',dictCode:''})
        fieldList.push({type:'int',value:'maxcarlv',text:'提交时最高汽车等级',dictCode:''})
        fieldList.push({type:'int',value:'videonum',text:'提交时累计观看视频次数',dictCode:''})
        fieldList.push({type:'double',value:'cash',text:'提交时红包币余额',dictCode:''})
        fieldList.push({type:'double',value:'money',text:'金额',dictCode:''})
        fieldList.push({type:'string',value:'state',text:'状态',dictCode:'audit_state'})
        fieldList.push({type:'datetime',value:'regtime',text:'注册时间'})
        fieldList.push({type:'datetime',value:'ttime',text:'提现时间'})
        fieldList.push({type:'datetime',value:'dtime',text:'到账时间'})
        fieldList.push({type:'Text',value:'data',text:'返回结果',dictCode:''})
        this.superFieldList = fieldList
      },
      audit(records,num){
        let localUrl=this.url.auditNo;
        if(num==0){
          localUrl=this.url.auditYes;
        }
        /*var params=Object.assign(sqp, this.queryParam, this.isorter ,this.filters);
        params.id=num;*/
        getAction(localUrl,{id: records.sourceid} ).then((res) => {
          if (res.success) {
            this.$message.success(res.message);
            this.modalFormOk();
          }
        })
      },
      searchType(num){
        if(num==0){

          this.btnIsActive1=true;
          this.btnIsActive2=false;
        }else{
          this.btnIsActive1=false;
          this.btnIsActive2=true;
        }
        this.searchQuery();
      },

    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
  .tab-search,.tab-search button{
    padding: 0;
    margin: 0;
  }
  .tab-search{
    background-color:#EFEFEF;
    padding: 2px;
    display: inline-block;
    width: 200px;
    height: 30px;
    margin:0 auto;
    float: left;
    border-radius: 5px;

  }
  .tab-search button{
    border-radius: 3px;
    border: none;
    width: 50%;
    height: 100%;
    outline:0;
  }
  .btnclass{
    background-color: #fafafa;
    color: #0b96f3;
  }
  .btnclass:focus{
    outline:0;
  }
  .linkColor{
    color: red;
  }
</style>